package companycomminutes;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.wipz.eoa.iphone.BaseServiceImpl;

public class ICompanyServiceImpl extends BaseServiceImpl  implements ICompanyService {

	@Override
	public List<CountryTree> getGroupByNode(String node) {
		Map<Object,Object> companygroupMap = new HashMap<Object,Object>();
		if("root".equals(node))
			companygroupMap.put("NODE","0");
		else
			companygroupMap.put("NODE",node);
		
		List<CountryTree> companygrouplist=new ArrayList<CountryTree>();
		List<Map> agencyByBusinessList = super.queryList("companygroup.query", companygroupMap);
		for (Map currentAgencyMap : agencyByBusinessList){
			CountryTree ct=new CountryTree();
			try{
				ct.setId((String)currentAgencyMap.get("ID"));
				ct.setText((String)currentAgencyMap.get("GROUP_NAME"));
				if(ct.getId().length()>5)
					ct.setLeaf(true);
				ct.setCls("folder");
				companygrouplist.add(ct);
			}catch(Exception e){
				e.printStackTrace();
			}
		}
		return companygrouplist;
	}

	@Override
	public List getCompanyUserByNode(String node) {
		Map<Object,Object> companygroupMap = new HashMap<Object,Object>();
		if("root".equals(node))
			companygroupMap.put("NODE","0");
		else
			companygroupMap.put("NODE",node);
		
		List<CountryTree> companygrouplist=new ArrayList<CountryTree>();
		List<Map> agencyByBusinessList = super.queryList("companyUser.query", companygroupMap);
		for (Map currentAgencyMap : agencyByBusinessList){
			CountryTree ct=new CountryTree();
			try{
				ct.setId((String)currentAgencyMap.get("ID"));
				ct.setText((String)currentAgencyMap.get("GROUP_NAME"));
			}catch(Exception e){
				e.printStackTrace();
			}
			ct.setLeaf(true);
			ct.setCls("folder");
			companygrouplist.add(ct);
		}
		return companygrouplist;
	}

}
